package metier.sess;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import metier.entities.Langue;

@Stateless(name="Langue")
public class LangueEJBImpl implements ILangueLocal{
	@PersistenceContext(unitName="PU_Cargaison")
	private EntityManager em;
	
	
	@Override
	public void addLangue(Langue l) {
		em.persist(l);
		
	}

	@Override
	public List<Langue> getAllLangues() {
		Query	req=em.createQuery("select sp from Langue sp ");
		  return req.getResultList();
	}

	@Override
	public Langue getLangue(Integer Id) {
		return em.find(Langue.class, Id);
	}

	@Override
	public void updateLangue(Langue d) {
		 em.merge(d);
		
	}

	@Override
	public void deleteLangue(Integer Id) {
		em.remove(getLangue(Id));
		
	}

	@Override
	public List<Langue> getAllActiveLangues() {
		Query	req=em.createQuery("select l from Langue l  where l.statut=true ");
		return req.getResultList();
	}
	

}
